﻿using System;
using System.Linq;
using NHibernate;
using NHibernate.Linq;
using Wikey.Entity;

namespace Wikey.Domain.Components {
    public class ModelContext : NHibernateContext {
        public ModelContext(ISessionSource source) : this(source.CreateSession()) { }
        public ModelContext(ISession session) : base(session) { }

        public IOrderedQueryable<User> Users {
            get { return Session.Linq<User>(); }
        }

        public IOrderedQueryable<Page> Pages {
            get { return Session.Linq<Page>(); }
        }

        public IOrderedQueryable<Tag> Tags {
            get { return Session.Linq<Tag>(); }
        }

        public IOrderedQueryable<Comment> Comments {
            get { return Session.Linq<Comment>(); }
        }

        public IOrderedQueryable<Template> Templates {
            get { return Session.Linq<Template>(); }
        }

        public IOrderedQueryable<Document> Documents {
            get { return Session.Linq<Document>(); }
        }

        public IOrderedQueryable<Macro> Macros {
            get { return Session.Linq<Macro>(); }
        }

        public IOrderedQueryable<Space> Spaces {
            get { return Session.Linq<Space>(); }
        }

        public IOrderedQueryable<ContentNode> ContentNodes
        {
            get { return Session.Linq<ContentNode>(); }
        }

        public IOrderedQueryable<Role> Roles
        {
            get { return Session.Linq<Role>(); }
        }

        public IOrderedQueryable<T> Get<T>() 
        {
            return Session.Linq<T>();
        }
    }
}
